
#ifndef MainFrame_H
#define MainFrame_H

#include <wx/odcombo.h>
#include <wx/notebook.h>

#include <wx/timer.h>
#include <wx/menu.h>

#include "tux.h"

enum
{
			ID_MENU_FILE_NEW_MESSENGER = 1000,
		

            ID_MENU_FILE_QUIT,

			ID_MENU_HELP_TEST,
			ID_MENU_HELP_TEST_PROXY,
            ID_MENU_HELP_ABOUT,
            ID_MENU_HELP_DEBUG,

            ID_TOOL_SIGNOUT
};

class MsnMessenger;
class MsnEvent;
class MsnSession;
class MessengerPanel;
class MessengerNotebook;

class TaskBarIcon;

class MainFrame: public wxFrame
{
friend class MessengerPanel;

private:
	wxMenuBar* menuBar;
    wxToolBar* toolBar ;
		
    TaskBarIcon* taskBarIcon;
	
	MessengerNotebook* messengerNotebook;

	wxLogWindow* logWindow;

	//wxTextCtrl* m_SearchTextCtrl;
	//wxOwnerDrawnComboBox* m_SearchComboBox;

	bool isIdle;

private:
	time_t lastStatusUpdate;
	wxTimer* mainTimer;

public:
	MainFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size);
	~MainFrame();

public:
	MessengerPanel* GetCurrentMessengerPanel();
	MsnMessenger* GetCurrentMessenger();

	//whether there's a online messenger 
	bool IsOnline();
	bool HasNewMessage();

	void UpdateUIWhenUserSignIn();
	void UpdateUIWhenUserSignOut();
	void UpdateUIWhenNewMsgArrive();	

	void ChangeStatusToIdle(bool isIdle);

	void OnOptions(wxCommandEvent& event);

private:
    void SetRecentContactList(const wxArrayString& contactList);

private:
		void CreateUI();
        void CreateMenuBar();
        void CreateToolBar();
        void CreateNotebook();

		void RecreateMenuBar();
		void RecreateToolBar();

		void UpdateUIText();
		void UpdateUIStatus();

		void UpdateTaskBarIcon();

		void UpdateStatusBarText(const wxString& text);

		void CheckLanguageMenu(wxMenu* langMenu);

		void OnClose(wxCloseEvent& event);

		void OnActivate(wxActivateEvent& event);

		void OnQuit(wxCommandEvent& event);
		void OnAbout(wxCommandEvent& event);		

        void OnToolSearch(wxCommandEvent& event);
   
        void OnChangeStatus(wxCommandEvent&);

		void OnNewPage(wxCommandEvent& event);
		void OnClosePage(wxCommandEvent& event);
		void OnCloseAll(wxCommandEvent& event);

		void OnSignOut(wxCommandEvent& event);

		void OnAddContact(wxCommandEvent& event);
		void OnAddGroup(wxCommandEvent& event);

        //void OnSignOut(wxCommandEvent& event);
		//void OnSignOutAll(wxCommandEvent& event);

        void OnRecentContact(wxCommandEvent& event);
		
		void OnTransferWindow(wxCommandEvent& event);


		void OnOpenMessageHistoryFolder(wxCommandEvent& event);
        void OnOpenReceivedFileFolder(wxCommandEvent& event);

		void OnLanguage(wxCommandEvent& event);

		void OnMessengerPanelChanged(wxNotebookEvent& event);

		void OnMessengerPanelClosed(wxCommandEvent& event);

		void OnMainTimer(wxTimerEvent& e);

		void OnTest(wxCommandEvent& event);
		void OnTestProxy(wxCommandEvent& event);
		void OnDebug(wxCommandEvent& event);
		void OnDebugReceived(wxCommandEvent& event);



DECLARE_EVENT_TABLE()
};

BEGIN_DECLARE_EVENT_TYPES()
    DECLARE_EVENT_TYPE(tuxEVT_LOG, -1)
END_DECLARE_EVENT_TYPES()


#endif // wxMAIN_H
